home *** CD-ROM | disk | FTP | other *** search
- Path: news.eden.com!usenet
- From: Shane Sadler <nexus@eden.com>
- Newsgroups: comp.lang.c
- Subject: Re: Do you have ever pass structures?
- Date: Wed, 21 Feb 1996 20:58:01 -0700
- Organization: Eden Matrix Services
- Message-ID: <312BE9C9.67A2284E@eden.com>
- References: <4ge8mi$qjm@srvr1.engin.umich.edu>
- NNTP-Posting-Host: net-1-215.austin.eden.com
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0 (X11; I; Linux 1.2.8 i586)
-
- HASDI RODZMANN HASHIM wrote:
-
- > So is there any REAL advantage is passing an entire structure? Do people
- > ever do it? I've some people's source code and almost always, they
- > pass pointers to structures instead of the structure itself. In a way,
- > passing a pointer to an array instead of the array itself might be
- > feature not a bug in C. :)
-
- Hasdi,
-
- As you know passing an entire structure to a function pushes that
- structure onto the stack. By passing pointers, you avoid that sort of
- overhead and your code is more efficient. When I'm writing what Mr.
- Collins would call "disposable programs," I might just declare my
- structures globally just out of laziness and expediency, but I can't
- think of a case in which I would pass the whole structure. So my answer
- would be "no". Of course, someone else may have experience with passing
- very small structures (one or two elements). There might be some
- advantage in this, but a "REAL" advantage? I doubt it. Depends on what
- you mean by "REAL," I guess...
-
- -- Shane
- ===================================================================
- S. M. Sadler
- e-mail: nexus@eden.com
- Web: http://www.eden.com/~nexus
-